package 面试.停止线程;
//判断线程是否停止状态



class MyThread_01 extends Thread {
    public void run(){
        super.run();
        for(int i=0; i<500000; i++){

            i++;
//            System.out.println("i="+(i+1));
        }
    }
}

public class Demo2 {
    public static void main(String args[]){
        Thread thread = new MyThread_01();
        thread.start();
        try {
            Thread.sleep(2000);
            thread.interrupt();

            System.out.println("stop 1??" + thread.interrupted());
            System.out.println("stop 2??" + thread.interrupted());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        Thread.currentThread().interrupt();
        System.out.println("stop 1??" + Thread.interrupted());
        System.out.println("stop 2??" + Thread.interrupted());

        System.out.println("End");


        Thread thread_01 = new MyThread_01();
        thread_01.start();
        thread_01.interrupt();
        System.out.println("stop 1??" + thread_01.isInterrupted());
        System.out.println("stop 2??" + thread_01.isInterrupted());
    }
}